程式:
import numpy as np
name = np.array(["張三","李四","石蓉","龍六"])
gender = np.array(["M","M","F","M"])
height = np.array([172,166,158,189])
weight = np.array([90,78,55,87])
scrore_math = np.array([45,74,88,61])
scrore_chinese = np.array([99,84,98,41])
scrore_english = np.array([66,84,68,31])
print ("班上男生的數學平均")
print (scrore_math[gender=="M"].mean())
結果:
班上男生的數學平均
60.0